from fasc_api.client.doc_client import DocClient
from fasc_api.client.service_client import ServiceClient
from fasc_api.exception.exceptions import ClientException
from fasc_api.exception.exceptions import ServerException

from init_demo_data import InitDemoData
api_client = InitDemoData.api_client
access_token = ServiceClient.get_access_token_value(api_client)
api_client.set_access_token(access_token)


# 上传即时文件
def file_upload_instant_demo():
    try:
        data = {
            'ownerId': {
                'idType': '主体类型： corp: 企业 , person: 个人',
                # 法大大平台为该企业在该应用appId范围内分配的唯一标识
                'openCorpId': InitDemoData.openCorpId,
                # (可选)法大大平台为该用户在该应用appId范围内分配的唯一标识
                'openUserId': InitDemoData.openUserId
            },
            'fileType': '文件的用途类型：doc：用于签署的文档, attach：用于签署文档的附件',
            'fileName': '文档名称',
            'fileUrl': '文件源URL地址',
            'fileContentHash': '文件的hash值(sha256)'
        }
        res = DocClient.file_upload_instant(api_client, '', data)
        print(res)
    except ClientException as e:
        print(e.__str__())
    except ServerException as e:
        print(e.__str__())

if __name__ == '__main__':
    file_upload_instant_demo()

